package org.sirmupadbapi.persistencia;

import org.sirmupadbapi.beans.Vehiclesfideicomiso;
import java.sql.Date; 
import org.sirmupadbapi.beans.*;
import org.sirmupadbapi.controller.*;
import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import java.util.*;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import java.util.Map;
import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
 import javax.sql.DataSource;
import org.sirmupadbapi.generales.Mensajeria;
import org.sirmupadbapi.generales.DataGManager;


/**
*
* @author
*/

public class VehiclesfideicomisoPersistencia implements Serializable {
private static final long serialVersionUID = 1L;
public static Exception excepcion;
public static boolean esMensaje = false;
public static Connection con = null;
public static java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/sirmupadbapi/properties/mensajes");
static DataGManager dataGManager;
static List<Vehiclesfideicomiso> list;

public VehiclesfideicomisoPersistencia(){
         esMensaje =false;
}


/**
*
* insert()
*/

public static boolean insert (Vehiclesfideicomiso vehiclesfideicomiso ) {
  excepcion = null;
  try {
      esMensaje =false;
   
   
   

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pinsert = null;
      String sql = "insert into vehiclesfideicomiso(IDVEHICULO,PLACA,IDRECIBO,FECHAFIDEICOMISO,IDENTIDAD,ACTIVO,IDMUNICIPIO,FECHA,USERNAME,IDRECIBOLIBERACION,FECHAFIDEICOMISOLIBERACION)  values(?,?,?,?,?,?,?,?,?,?,?)";
      pinsert = con.prepareStatement(sql);
              pinsert.setLong(1,vehiclesfideicomiso.getIDVEHICULO());
        pinsert.setString(2,vehiclesfideicomiso.getPLACA());
        pinsert.setInt(3,vehiclesfideicomiso.getIDRECIBO());
        pinsert.setDate(4,vehiclesfideicomiso.getFECHAFIDEICOMISO());
        pinsert.setInt(5,vehiclesfideicomiso.getIDENTIDAD());
        pinsert.setString(6,vehiclesfideicomiso.getACTIVO());
        pinsert.setString(7,vehiclesfideicomiso.getIDMUNICIPIO());
        pinsert.setDate(8,vehiclesfideicomiso.getFECHA());
        pinsert.setString(9,vehiclesfideicomiso.getUSERNAME());
        pinsert.setInt(10,vehiclesfideicomiso.getIDRECIBOLIBERACION());
        pinsert.setDate(11,vehiclesfideicomiso.getFECHAFIDEICOMISOLIBERACION());
      int filas= pinsert.executeUpdate();
      pinsert.close();
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
 }


/**
*
* update()
*/

public static boolean update(Vehiclesfideicomiso vehiclesfideicomiso ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update vehiclesfideicomiso set    ";
      pupdate= con.prepareStatement(sql);
      pupdate.setLong(1,vehiclesfideicomiso.getIDVEHICULO());
pupdate.setString(2,vehiclesfideicomiso.getPLACA());
pupdate.setInt(3,vehiclesfideicomiso.getIDRECIBO());
pupdate.setDate(4,vehiclesfideicomiso.getFECHAFIDEICOMISO());
pupdate.setInt(5,vehiclesfideicomiso.getIDENTIDAD());
pupdate.setString(6,vehiclesfideicomiso.getACTIVO());
pupdate.setString(7,vehiclesfideicomiso.getIDMUNICIPIO());
pupdate.setDate(8,vehiclesfideicomiso.getFECHA());
pupdate.setString(9,vehiclesfideicomiso.getUSERNAME());
pupdate.setInt(10,vehiclesfideicomiso.getIDRECIBOLIBERACION());
pupdate.setDate(11,vehiclesfideicomiso.getFECHAFIDEICOMISOLIBERACION());
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* update()
*/

public static boolean update(String sqlupdate ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update  vehiclesfideicomiso set " + sqlupdate +"";
      pupdate= con.prepareStatement(sql);
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* updatePrimaryKey()
*/

public static boolean updatePrimaryKey(Vehiclesfideicomiso vehiclesfideicomiso_old , Vehiclesfideicomiso vehiclesfideicomiso) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pupdate = null;
      String sql = "update vehiclesfideicomiso set    ";
      pupdate= con.prepareStatement(sql);
      
      int filas= pupdate.executeUpdate();
      pupdate.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.noupdate"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(Vehiclesfideicomiso vehiclesfideicomiso ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from vehiclesfideicomiso   ";
      pdelete= con.prepareStatement(sql);
      
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* delete()
*/

public static boolean delete(String sqldelete ) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from vehiclesfideicomiso where " + sqldelete +"";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodelete"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* deleteAll()
*/

public static boolean deleteAll() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
      PreparedStatement pdelete = null;
      String sql = "delete from vehiclesfideicomiso  ";
      pdelete= con.prepareStatement(sql);
      int filas= pdelete.executeUpdate();
      pdelete.close();
      if (filas <= 0){
          excepcion=new Exception(bundle.getString("msg.nodeleteall"));
          esMensaje =true;
          return false;
      }
      return true;
   } catch (Exception e) {
      excepcion = e;
   } finally {
  }
  return false;
}


/**
*
* exists()
*/



public static boolean exists(Vehiclesfideicomiso vehiclesfideicomiso) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return false;
  }
        String sql = "select * from vehiclesfideicomiso where IDVEHICULO='"+vehiclesfideicomiso.getIDVEHICULO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +" " + bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return false;
   }
    rs.close();
    psquery.close();
 return true;
} catch (Exception ex) {
      excepcion = ex;
}
  return false;
}


/**
*
* findByPrimaryKey()
*/



public static Vehiclesfideicomiso findByPrimaryKey(Vehiclesfideicomiso vehiclesfideicomiso) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
  String sql = "select * from vehiclesfideicomiso where IDVEHICULO='"+vehiclesfideicomiso.getIDVEHICULO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
            
            
            vehiclesfideicomiso.setIDVEHICULO(rs.getLong("IDVEHICULO"));
vehiclesfideicomiso.setPLACA(rs.getString("PLACA"));
vehiclesfideicomiso.setIDRECIBO(rs.getInt("IDRECIBO"));
vehiclesfideicomiso.setFECHAFIDEICOMISO(rs.getDate("FECHAFIDEICOMISO"));
vehiclesfideicomiso.setIDENTIDAD(rs.getInt("IDENTIDAD"));
vehiclesfideicomiso.setACTIVO(rs.getString("ACTIVO"));
vehiclesfideicomiso.setIDMUNICIPIO(rs.getString("IDMUNICIPIO"));
vehiclesfideicomiso.setFECHA(rs.getDate("FECHA"));
vehiclesfideicomiso.setUSERNAME(rs.getString("USERNAME"));
vehiclesfideicomiso.setIDRECIBOLIBERACION(rs.getInt("IDRECIBOLIBERACION"));
vehiclesfideicomiso.setFECHAFIDEICOMISOLIBERACION(rs.getDate("FECHAFIDEICOMISOLIBERACION"));
    }
    rs.close();
    psquery.close();
 return vehiclesfideicomiso;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDVEHICULO()
*/

public static List<Vehiclesfideicomiso> findByIDVEHICULO(Vehiclesfideicomiso vehiclesfideicomiso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
      String sql = "select * from vehiclesfideicomiso where IDVEHICULO='"+vehiclesfideicomiso.getIDVEHICULO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByPLACA()
*/

public static List<Vehiclesfideicomiso> findByPLACA(Vehiclesfideicomiso vehiclesfideicomiso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
      String sql = "select * from vehiclesfideicomiso where PLACA='"+vehiclesfideicomiso.getPLACA()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDRECIBO()
*/

public static List<Vehiclesfideicomiso> findByIDRECIBO(Vehiclesfideicomiso vehiclesfideicomiso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
      String sql = "select * from vehiclesfideicomiso where IDRECIBO='"+vehiclesfideicomiso.getIDRECIBO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFECHAFIDEICOMISO()
*/

public static List<Vehiclesfideicomiso> findByFECHAFIDEICOMISO(Vehiclesfideicomiso vehiclesfideicomiso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
      String sql = "select * from vehiclesfideicomiso where FECHAFIDEICOMISO='"+vehiclesfideicomiso.getFECHAFIDEICOMISO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDENTIDAD()
*/

public static List<Vehiclesfideicomiso> findByIDENTIDAD(Vehiclesfideicomiso vehiclesfideicomiso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
      String sql = "select * from vehiclesfideicomiso where IDENTIDAD='"+vehiclesfideicomiso.getIDENTIDAD()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByACTIVO()
*/

public static List<Vehiclesfideicomiso> findByACTIVO(Vehiclesfideicomiso vehiclesfideicomiso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
      String sql = "select * from vehiclesfideicomiso where ACTIVO='"+vehiclesfideicomiso.getACTIVO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDMUNICIPIO()
*/

public static List<Vehiclesfideicomiso> findByIDMUNICIPIO(Vehiclesfideicomiso vehiclesfideicomiso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
      String sql = "select * from vehiclesfideicomiso where IDMUNICIPIO='"+vehiclesfideicomiso.getIDMUNICIPIO()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFECHA()
*/

public static List<Vehiclesfideicomiso> findByFECHA(Vehiclesfideicomiso vehiclesfideicomiso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
      String sql = "select * from vehiclesfideicomiso where FECHA='"+vehiclesfideicomiso.getFECHA()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByUSERNAME()
*/

public static List<Vehiclesfideicomiso> findByUSERNAME(Vehiclesfideicomiso vehiclesfideicomiso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
      String sql = "select * from vehiclesfideicomiso where USERNAME='"+vehiclesfideicomiso.getUSERNAME()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByIDRECIBOLIBERACION()
*/

public static List<Vehiclesfideicomiso> findByIDRECIBOLIBERACION(Vehiclesfideicomiso vehiclesfideicomiso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
      String sql = "select * from vehiclesfideicomiso where IDRECIBOLIBERACION='"+vehiclesfideicomiso.getIDRECIBOLIBERACION()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* findByFECHAFIDEICOMISOLIBERACION()
*/

public static List<Vehiclesfideicomiso> findByFECHAFIDEICOMISOLIBERACION(Vehiclesfideicomiso vehiclesfideicomiso,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
      String sql = "select * from vehiclesfideicomiso where FECHAFIDEICOMISOLIBERACION='"+vehiclesfideicomiso.getFECHAFIDEICOMISOLIBERACION()+"'";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* locateByParameters()
*/

public static List<Vehiclesfideicomiso> locateByParameters(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
       list = new ArrayList<Vehiclesfideicomiso>();
  String sql = "select * from vehiclesfideicomiso";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      int i = 0;
      while (it.hasNext()) {
          if (i != 0){
            sb.append(" and ");
         }
         i++;
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"= '"+  e.getValue()+"'");
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* Double fFunc(String funcion, String campo)
*/



public static Double func(String funcion, String campo) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from vehiclesfideicomiso";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* Double func(String funcion, String campo,String where)
*/



public static Double func(String funcion, String campo, String where) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0.0;
  }
      String sql = "select "+funcion+"("+campo+") as contador from vehiclesfideicomiso where "+where +" ";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0.0;
   }
    Double tmp =0.0;
   rs.beforeFirst();
   while (rs.next()) {
    tmp =  rs.getDouble("contador");
    }
    rs.close();
    psquery.close();
 return tmp;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0.0;
}


/**
*
* count()
*/



public static Integer count() {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from vehiclesfideicomiso";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* count(String sqlquery)
*/



public static Integer count(String sqlquery) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return 0;
  }
      String sql = "select count(*) as contador from vehiclesfideicomiso where  " + sqlquery +"";
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return 0;
   }
   rs.beforeFirst();
   while (rs.next()) {
    x =  rs.getInt("contador");
    }
    rs.close();
    psquery.close();
 return x;
} catch (Exception ex) {
      excepcion = ex;
}
  return 0;
}


/**
*
* query()
*/

public static List<Vehiclesfideicomiso> query(String query,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
        list = new ArrayList<Vehiclesfideicomiso>();
  String sql = "select * from vehiclesfideicomiso where " + query +"";
  if (query == null || query.equals("")) {
  return null;
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
   
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
}


/**
*
* getListRecords()
*/

public static List<Vehiclesfideicomiso> getListRecords(Map parametros,boolean withRelation) {
  excepcion = null;
  try {
      esMensaje =false;

  con= dataGManager.getCon();
  if (con == null) {
      excepcion=new Exception(bundle.getString("msg.noconecction"));
      return null;
  }
      list = new ArrayList<Vehiclesfideicomiso>();
  String sql = "select * from vehiclesfideicomiso";
  if (parametros != null) {
      Iterator it = parametros.entrySet().iterator();
      StringBuilder sb = new StringBuilder("");
      while (it.hasNext()) {
        Map.Entry e = (Map.Entry) it.next();
        sb.append(e.getKey() +"="+  e.getValue());
      }
      if (!sb.toString().equals("")){
         sql = sql + " where " + sb.toString();
      }
   }
  PreparedStatement psquery = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
   ResultSet rs = psquery.executeQuery();
   rs.next();
   int x = rs.getRow();
   if (x == 0) {
          excepcion=new Exception(bundle.getString("msg.nofoundrecords") + "vehiclesfideicomiso" +"  "+ bundle.getString("msg.withcode"));
          esMensaje =true;
      rs.close();
      psquery.close();
      return null;
   }
   rs.beforeFirst();
   while (rs.next()) {
       
        Vehiclesfideicomiso vehiclesfideicomiso2 = new Vehiclesfideicomiso(
         rs.getLong("IDVEHICULO"),rs.getString("PLACA"),rs.getInt("IDRECIBO"),rs.getDate("FECHAFIDEICOMISO"),rs.getInt("IDENTIDAD"),rs.getString("ACTIVO"),rs.getString("IDMUNICIPIO"),rs.getDate("FECHA"),rs.getString("USERNAME"),rs.getInt("IDRECIBOLIBERACION"),rs.getDate("FECHAFIDEICOMISOLIBERACION"));
            
            
       list.add(vehiclesfideicomiso2);
    }
    rs.close();
    psquery.close();
    return list;
} catch (Exception ex) {
      excepcion = ex;
}
  return null;
 }


}
